unit data_module;

interface

uses
  SysUtils, Classes, DBXMySQL, FMTBcd,
  DBClient, Provider, DB, SqlExpr, SimpleDS,
  DBAccess, MyAccess, MemDS;

type
  Tdata_mod = class(TDataModule)
    sql_connection: TMyConnection;
    prepod_table: TMyTable;
    study_types_table: TMyTable;
    disciplines_query: TMyQuery;
    discipline_for_open_rating_query: TMyQuery;
    prepod_for_user_combo_query: TMyQuery;
    study_plan_query: TMyQuery;
    marks_query: TMyQuery;
    prepod_source: TMyDataSource;
    study_types_source: TMyDataSource;
    schools_source: TMyDataSource;
    profiles_source: TMyDataSource;
    disciplines_source: TMyDataSource;
    groups_source: TMyDataSource;
    students_source: TMyDataSource;
    steps_source: TMyDataSource;
    substeps_source: TMyDataSource;
    marks_source: TMyDataSource;
    prepod_for_user_combo_source: TMyDataSource;
    study_plan_source: TMyDataSource;
    discipline_for_open_rating_source: TMyDataSource;
    groups_for_prepod_unit_query: TMyQuery;
    groups_for_prepod_unit_source: TMyDataSource;
    discipline_for_prepod_query: TMyQuery;
    discipline_for_prepod_source: TMyDataSource;
    rating_step_query: TMyQuery;
    rating_step_source: TMyDataSource;
    MyCommand1: TMyCommand;
    MyQuery1: TMyQuery;
    assistents_query: TMyQuery;
    assistens_source: TMyDataSource;
    groups_query: TMyQuery;
    substeps_query: TMyQuery;
    rating_substep_query: TMyQuery;
    rating_substep_source: TMyDataSource;
    steps_query: TMyQuery;
    substeps_for_rating_solve_query: TMyQuery;
    substeps_for_rating_solve_source: TMyDataSource;
    profiles_query: TMyQuery;
    schools_query: TMyQuery;
    students_query: TMyQuery;
    MyQuery2: TMyQuery;
    MyQuery3: TMyQuery;
    MyQuery4: TMyQuery;
    MyQuery5: TMyQuery;
    step_dates_query: TMyQuery;
    substep_dates_query: TMyQuery;
    step_dates_source: TMyDataSource;
    substep_dates_source: TMyDataSource;
    ss_r_dates_query: TMyQuery;
    ss_r_dates_source: TMyDataSource;
    ss_r_decay_query: TMyQuery;
    ss_r_decay_source: TMyDataSource;

    function try_connect(host,port:string; var msg:string):boolean;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  data_mod: Tdata_mod;

implementation

{%CLASSGROUP 'System.Classes.TPersistent'}

{$R *.dfm}

function Tdata_mod.try_connect(host: string; port: string; var msg:string):boolean;
begin
  sql_connection.Server:=host;
  sql_connection.Port:=StrToInt(port);
  try
    sql_connection.Connected:=true;
    prepod_table.Active:=true;
    study_types_table.Active:=true;
    schools_query.Active:=true;
    profiles_query.Active:=true;
    disciplines_query.Active:=true;
    groups_query.Active:=true;
    students_query.Active:=true;
    //lesson_types_table.Active:=true;
    //marks_table.Active:=true;
    discipline_for_open_rating_query.Active:=true;
    steps_query.Active:=true;
    substeps_query.Active:=true;
    marks_query.Active:=true;
    prepod_for_user_combo_query.Active:=true;
    study_plan_query.Active:=true;
    //lesson_types_for_add_unit_query.Active:=true;
    //lesson_types_for_score_page_query.Active:=true;
    rating_step_query.Active:=true;
    groups_for_prepod_unit_query.Active:=true;
    discipline_for_prepod_query.Active:=true;
    substeps_for_rating_solve_query.Active:=true;
    assistents_query.Active:=true;
    MyQuery1.Active:=true;
    MyQuery2.Active:=true;
    MyQuery3.Active:=true;
    MyQuery4.Active:=true;
    MyQuery5.Active:=true;
    //MyQuery2.Active:=true;
    step_dates_query.Active:=true;
    substep_dates_query.Active:=true;
    ss_r_dates_query.Active:=true;
    ss_r_decay_query.Active:=true;
    try_connect:=true;
  except on e:Exception do
  begin
    try_connect:=false;
    msg:=e.Message;
  end;
  end;
end;

end.
